﻿using System.Drawing;
using System.IO;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.ADF.BaseClasses;
using PlanningGIS.Framework;
using PlanningGIS.DataConvert.form;

namespace PlanningGIS.DataConvert.button
{
    /// <summary>
    /// 入库规则管理
    /// </summary>
    internal class btnDataImportRule : BaseCommand
    {
        /// <summary>
        /// 
        /// </summary>
        IApplication m_Application = null;

        /// <summary>
        /// 
        /// </summary>
        private FrmDataImportRule m_frmDataImportRulet1 = null;

        /// <summary>
        /// 
        /// </summary>
        public btnDataImportRule()
        {
            base.m_caption = "建库方案管理";
            base.m_toolTip = base.m_caption;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hook"></param>
        public override void OnCreate(object hook)
        {
            m_Application = hook as IApplication;
        }

        /// <summary>
        /// 
        /// </summary>
        public override bool Enabled
        {
            get
            {
                if ((m_Application as IFramework).IsMapCtrlactive && (m_Application.Document != null))
                {
                    return true;
                }
                return false;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public override void OnClick()
        {
            base.OnClick();
            if ((m_Application as IFramework).IsMapCtrlactive)
            {
                if (m_frmDataImportRulet1 == null || m_frmDataImportRulet1.IsDisposed)
                {
                    m_frmDataImportRulet1 = new FrmDataImportRule();
                    m_frmDataImportRulet1.Show((m_Application as IFramework).MdiForm);
                }
                else
                {
                    m_frmDataImportRulet1.BringToFront();
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public override int Bitmap
        {
            get
            {
                string bitmapResourceName = "PlanningGIS.DataConvert.Res." + this.GetType().Name + ".png";
                return new Bitmap(GetType().Assembly.GetManifestResourceStream(bitmapResourceName)).GetHbitmap().ToInt32();
            }
        }

    }
}
